﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
namespace DataAccess
{
    public class DataAccess
    {
        public SqlConnection KetNoi()
        {
            return new SqlConnection("Data Source=UT-CUI-BAP;Initial Catalog=Test;Integrated Security=True");
        }
        public DataTable LayDuLieu(string sql)
        {
            //DataSet ds = new DataSet();
            DataTable tb= new DataTable();
            SqlConnection con = KetNoi();
            SqlDataAdapter ad = new SqlDataAdapter(sql, con);
            ad.Fill(tb);
            return tb;             
        }
        public void ExcuteNonQuery(string sql)
        {
            SqlConnection con = KetNoi();
            con.Open();
            SqlCommand cmd = new SqlCommand(sql, con);
            cmd.ExecuteNonQuery();
            cmd.Dispose();
            con.Close();
        }
      
    }
}
